<template>
    <div class="m-style have-nav">
        <block-index-nav-bar :title="'固定资产列表'"></block-index-nav-bar>
        <div>
            <van-row class="title-search">
                <van-col span="16">
                    <van-search
                        v-model="number"
                        placeholder="请输入设备编号"
                        @search="onSearch"
                    >
                    </van-search>
                </van-col>
                <van-col span="8" class="title-search-btn-group">
                    <van-button @click="onSearch">搜索</van-button>
                </van-col>
            </van-row>

            <click_pageList
                ref="pageList"
                :url="url"
                :cols="cols"
                :list-cond="listCond"
                @toDetail="toDetail"
            >
                <template v-slot="scope">
                    <strong>{{ scope.row.name }}</strong>
                </template>
            </click_pageList>

        </div>

    </div>
</template>

<script>
import blockIndexNavBar from "@/components/blockIndexNavBar";
import {API_URL} from "@/config/urlInfo";
import click_pageList from "@/uitl/click_pageList";

export default {
    name: "Index",
    components: {
        blockIndexNavBar,
        click_pageList
    },
    data() {
        return {
            number: "",
            url: API_URL.aloneInventory,
            cols: {
                show: [
                    {title: '盘点总数', field: 'total'},
                    {title: '开始时间', field: 'startDate'},
                    {title: '结束时间', field: 'endDate'},
                    {title: '已盘点', field: 'count'},
                    {title: '盘点率', field: 'stockRate'},
                    {title: '状态', field: 'type_CN'},
                    {title: '备注', field: 'desc'},
                ],
                // hide: [
                //     {title: '通讯地址', field: 'POST_ADDR'},
                //     {title: '开户证件号码', field: 'CERT_CODE'},
                //     {title: '联系人', field: 'CONTACT_NAME'},
                //     {title: '主管客户经理', field: 'CUST_MGR'},
                //     {title: '主管机构', field: 'MAIN_BR_ID'}
                // ]
            },
            show: true,
            loading: false,
            listCond: {}

        }
    },
    methods: {
        toDetail(item) {
            console.log("xxxxxxxxx", item)
            if (item.type === 'ToIssued') {
                this.$notify({type: 'danger', message: '当前计划代下发'});
                return
            }
            this.$router.push({path: '/assets-mobile/inventoryScanner', query: {id: item.id}});
        },
        onSearch() {
            this.listCond = {
                number: this.number
            };
        },
        onLoad() {
            // 异步更新数据
            // setTimeout 仅做示例，真实场景中一般为 ajax 请求
            setTimeout(() => {
                for (let i = 0; i < 10; i++) {
                    this.list.push(this.list.length + 1);
                }

                // 加载状态结束
                this.loading = false;

                // 数据全部加载完成
                if (this.list.length >= 40) {
                    this.finished = true;
                }
            }, 1000);
        },
    }
}
</script>

<style scoped>

</style>